package com.block.account.service.impl;

import com.block.account.model.dto.EntryAccountDTO;
import com.block.account.service.IAccountItemSpecialHisService;
import com.block.db.entity.AccountItemProductHis;
import com.block.db.entity.AccountItemSpecial;
import com.block.db.entity.AccountItemSpecialHis;
import com.block.db.mapper.AccountItemSpecialHisMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

/**
 * <p>
 * 机构账户流水表 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-07-29
 */
@Service
public class AccountItemSpecialHisServiceImpl extends ServiceImpl<AccountItemSpecialHisMapper, AccountItemSpecialHis> implements IAccountItemSpecialHisService {

    @Override
    public boolean saveAccountHisInfo(AccountItemSpecial accountItemSpecial, EntryAccountDTO entryAccountDTO) {
        AccountItemSpecialHis itemHis = new AccountItemSpecialHis();
        itemHis.setDateInfo(LocalDate.now().toString());
        itemHis.setBillDateInfo(entryAccountDTO.getBillDateInfo());

        itemHis.setAccountId(Integer.valueOf(entryAccountDTO.getItemAccountId()));

        itemHis.setInfoId(String.valueOf(accountItemSpecial.getInfoId()));
        itemHis.setInfoName(accountItemSpecial.getInfoName());

        itemHis.setActionType(entryAccountDTO.getActionType());

        itemHis.setChangeAmount(entryAccountDTO.getChangeAmount());
        itemHis.setOriginAmount(entryAccountDTO.getOriginAmount());
        itemHis.setCurrentAmount(entryAccountDTO.getCurrentAmount());

        itemHis.setDataId(entryAccountDTO.getExtData());

        itemHis.setOperatorId(entryAccountDTO.getOperatorId());
        itemHis.setOperatorName(entryAccountDTO.getOperatorName());

        boolean saveRes = this.save(itemHis);
        return saveRes;
    }
}
